#include "miniutil/logservice.h"
#include "miniutil/thread.h"
#include "miniutil/threadpool.h"
#include "minitest/testcase.h"
#include "miniutil/tinyxml.h"
#include "miniutil/strutil.h"

#ifdef WIN32
#include "windows.h"
#endif


class logservice_case : public testcase
{
public:
    logservice_case()
    {
        miniutil::frame::LogService::InitService();
    }

    ~logservice_case()
    {
    }

    int entryfunc()
    {
        //FAUTOENTRY;
        FENTRY;
        FRETURN(0);
    }

	virtual void test()
	{
        miniutil::frame::galoggservice.Start();
        const char* configxml = 
            "<?xml version='1.0'?>"
            "<loggers>"
                "<logger name='consolelogger' >"
                    "<config level='debug|crit|trace'></config>"
                "</logger>"
            "</loggers>";


        miniutil::tinyxml::TiXmlDocument tdoc;
        tdoc.Parse(configxml);
        
        miniutil::frame::galoggservice.config(tdoc.RootElement());
        miniutil::frame::galoggservice.log(miniutil::frame::Logger::LOG_LEVEL_DEBUG, "aaa\n");
        miniutil::frame::galoggservice.log_time_thread(miniutil::frame::Logger::LOG_LEVEL_DEBUG, "bbb\n");
        F_DEBUG("fdebug\n");
        FL_DEBUG("fdebug %d\n",111);
        
        entryfunc();
        miniutil::thread::sleep(100);
        miniutil::frame::galoggservice.Stop();

		return;
	}
};

testcase * t_logservice_1  = new logservice_case() ;